package com.zp.self;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * Created by zengpeng on 2020/12/07
 */
@SpringBootApplication
@RestController
@EnableHystrix
public class HystrixApplication {
    @Bean
    @LoadBalanced
    RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Resource
    HystrixService hystrixService;

    public static void main(String[] args) {
        SpringApplication.run(HystrixApplication.class, args);
    }

    @GetMapping("/hystrix-test")
    public Object hystrix(String name){
        return hystrixService.rpcRequest(name);
    }

}